package patrol.mobile.com.mobilepatrol.activity.office;

import java.util.ArrayList;
import java.util.List;

import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.bean.GridViewAddTitleBean;
import patrol.mobile.com.mobilepatrol.bean.HomeDataBean;
import patrol.mobile.com.mobilepatrol.bean.MenuBean;

/**
 * Created by K on 2018/9/11.
 * 各个首页数据操作
 */

public class HomeDataHelper {

    private static HomeDataHelper mHomeDataHelper;

    private HomeDataHelper() {
    }

    public static HomeDataHelper getInstance() {
        if (mHomeDataHelper == null) {
            synchronized (HomeDataHelper.class) {
                if (mHomeDataHelper == null) {
                    mHomeDataHelper = new HomeDataHelper();
                }
            }
        }
        return mHomeDataHelper;
    }

    public static List<HomeDataBean> getHomeData(String[] stringTopTitleArray,
                                                 String[] stringTopTitleSub1Array,
                                                 String[] stringTopTitleSub2Array,
                                                 String[] stringTopTitleSub3Array,
                                                 int[] img1,int[] img2,int[] img3) {
        List<HomeDataBean> list1 = new ArrayList<>();
        for (int i = 0; i < stringTopTitleArray.length; i++) {
            HomeDataBean homeDataBean = new HomeDataBean();
            homeDataBean.setTopTitle(stringTopTitleArray[i]);
            List<HomeDataBean.DataBean> list2 = new ArrayList<>();
            if (i == 0) {
                for (int i1 = 0; i1 < stringTopTitleSub1Array.length; i1++) {
                    HomeDataBean.DataBean dataBean = new HomeDataBean.DataBean(stringTopTitleSub1Array[i1], img1[i1]);
                    list2.add(dataBean);
                }
            } else if (i == 1) {
                for (int i1 = 0; i1 < stringTopTitleSub2Array.length; i1++) {
                    HomeDataBean.DataBean dataBean = new HomeDataBean.DataBean(stringTopTitleSub2Array[i1], img2[i1]);
                    list2.add(dataBean);
                }
            } else {
                for (int i1 = 0; i1 < stringTopTitleSub3Array.length; i1++) {
                    HomeDataBean.DataBean dataBean = new HomeDataBean.DataBean(stringTopTitleSub3Array[i1], img3[i1]);
                    list2.add(dataBean);
                }
            }
            homeDataBean.setData(list2);
            list1.add(homeDataBean);
        }
        return list1;
    }

    public static List<HomeDataBean> getHomeData(String[] stringTopTitleArray,
                                                 String[] stringTopTitleSub1Array,
                                                 String[] stringTopTitleSub2Array,
                                                 int[] img1, int[] img2, List<MenuBean> menuBeanList) {
        List<HomeDataBean> list1 = new ArrayList<>();
        for (int i = 0; i < stringTopTitleArray.length; i++) {
            HomeDataBean homeDataBean = new HomeDataBean();
            homeDataBean.setTopTitle(stringTopTitleArray[i]);
            List<HomeDataBean.DataBean> list2 = new ArrayList<>();
            if (i == 0) {
                for (int i1 = 0; i1 < stringTopTitleSub1Array.length; i1++) {
                    HomeDataBean.DataBean dataBean = new HomeDataBean.DataBean(stringTopTitleSub1Array[i1], img1[i1]);
                    list2.add(dataBean);
                }
            } else if (i == 1) {
                for (int i1 = 0; i1 < stringTopTitleSub2Array.length; i1++) {
                    HomeDataBean.DataBean dataBean = new HomeDataBean.DataBean(stringTopTitleSub2Array[i1], img2[i1]);
                    list2.add(dataBean);
                }
            }
            homeDataBean.setData(list2);
            list1.add(homeDataBean);
        }
        return list1;
    }
    public static List<HomeDataBean> getHomeDataYW(String[] stringTopTitleArray,
                                                   String[] stringTopTitleSub1Array,
                                                   String[] stringTopTitleSub2Array,
                                                   String[] stringTopTitleSub3Array,
                                                   String[] stringTopTitleSub4Array,
                                                   int[] img1,int[] img2,int[] img3,int[] img4) {
        List<HomeDataBean> list1 = new ArrayList<>();
        for (int i = 0; i < stringTopTitleArray.length; i++) {
            HomeDataBean homeDataBean = new HomeDataBean();
            homeDataBean.setTopTitle(stringTopTitleArray[i]);
            List<HomeDataBean.DataBean> list2 = new ArrayList<>();
            if (i == 0) {
                for (int i1 = 0; i1 < stringTopTitleSub1Array.length; i1++) {
                    HomeDataBean.DataBean dataBean = new HomeDataBean.DataBean(stringTopTitleSub1Array[i1], img1[i1]);
                    list2.add(dataBean);
                }
            } else if (i == 1) {
                for (int i1 = 0; i1 < stringTopTitleSub2Array.length; i1++) {
                    HomeDataBean.DataBean dataBean = new HomeDataBean.DataBean(stringTopTitleSub2Array[i1], img2[i1]);
                    list2.add(dataBean);
                }
            }else if (i==2){
                for (int i1 = 0; i1 < stringTopTitleSub3Array.length; i1++) {
                    HomeDataBean.DataBean dataBean = new HomeDataBean.DataBean(stringTopTitleSub3Array[i1], img3[i1]);
                    list2.add(dataBean);
                }
            }

            else {
                for (int i1 = 0; i1 < stringTopTitleSub4Array.length; i1++) {
                    HomeDataBean.DataBean dataBean = new HomeDataBean.DataBean(stringTopTitleSub4Array[i1], img4[i1]);
                    list2.add(dataBean);
                }
            }
            homeDataBean.setData(list2);
            list1.add(homeDataBean);
        }
        return list1;
    }
    /**
     * 设置第一块数据
     */
    public static List<GridViewAddTitleBean> getGridData(String[] strings, int[] imgs) {
        List<GridViewAddTitleBean> list = new ArrayList<>();
        for (int i = 0; i < strings.length; i++) {
            GridViewAddTitleBean gridViewAddTitleBean = new GridViewAddTitleBean();
            gridViewAddTitleBean.setTitle(strings[i]);
            gridViewAddTitleBean.setImage(imgs[i]);
            list.add(gridViewAddTitleBean);
        }
        return list;
    }
}
